// pages/shangluoyuehuiquncheng/shangluoyuehuiquncheng.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    page: Number, // 起始页码
    videlist: [],
    shi_q: true,
    shi_w: true,
    L3name: '',
    L4name: '',

    city:'',
  },

  quxian() {
    this.setData({
      shi_q: false,
    })
  },

  wangdian() {

    this.setData({
      shi_w: false,
    })

  },


  
  region() {
    wx.request({
      url: app.globalData.interface+'/shangLuoWork/API_2026_weinanBusinessListdistrict',
      method: 'POST',
      data: {
        OPEN_ID: this.data.openid, //用户OPEN_ID
        session_key: this.data.session_key,
        OPEN_UUID: this.data.jiami
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: res => {
        console.log(res.data.data);
        this.setData({
          city: res.data.data,
        })

      }
    })
  },


  buttn_a(e) {
    console.log(e);
    console.log(e.currentTarget.dataset.item.saix);

    this.setData({
     
      chunname: e.currentTarget.dataset.item.saix,
      shi_chun: true
    })
  },



  buttn_c(e) {
    console.log(e);
    console.log(e.currentTarget.dataset.item.L3name);
    console.log(e.currentTarget.dataset.item.wangdian);
    this.setData({
      business: e.currentTarget.dataset.item.wangdian,
      L3name: e.currentTarget.dataset.item.district,
      shi_q: true
    })
  },


  buttn_d(e) {
    console.log(e);
    console.log(e.currentTarget.dataset.item.L4name);
    this.setData({
      L4name: e.currentTarget.dataset.item.business_phone,
      shi_w: true,
    })
    this.getvidelist() 

    
  },



  //网点
  Outlets() {

    if (this.data.L3name == '') {
      wx.showToast({
        icon: 'none',
        title: '请先选择区县',
        duration: 1800
      })
    } else {
      this.setData({
        shi_w: false,
      })


    }
  },







  


  
  getvidelist() {
    wx.showLoading({
      title: '加载中...',
    })



    wx.request({
      url: app.globalData.interface+'/shangLuoWork/API_2027_weinanBusinessList',
      method: 'POST',
      data: {
        business_phone: this.data.L4name, 
        OPEN_ID: this.data.openid, //用户OPEN_ID
        session_key: this.data.session_key,
        OPEN_UUID: this.data.jiami
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: res => {
        console.log('res', res);
        console.log('res', res.data.result);
        wx.hideLoading()
        if (res.data.result == 'success') {

          this.setData({
            videlist: res.data.data,
         
          })

        } else {
          wx.showModal({
            title: "暂无该条数据",
            content: '无数据',
            showCancel: false,
          });
        }
      },
      fail: (res => {
        wx.hideLoading()
      })
    })


  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
  
    // setTimeout(() => {
    // }, 500);
      this.setData({
        openid: app.globalData.openid,
        jiami: app.globalData.jiami,
        OPEN_ID: app.globalData.openid,
        session_key: app.globalData.session_key,
      })
  

    this.region()
    this.getvidelist()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})